Playing with matplotlib

Variable declarations

DEM_filepath – path to DEM raster
sample_points_filepath – path to sample points shapefile


In [ ]:
DEM_filepath = ""

In [ ]:
sample_points_filepath = ""

Import statements


In [3]:
import matplotlib.pylab as plt

In [4]:
%matplotlib inline

In [1]:
import rasterio
import fiona

Examples


In [5]:
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()



In [17]:
with rasterio.drivers():
    with rasterio.open(DEM_filepath) as source_dem:
        array_dem = source_dem.read(1)
        source_dem.close()

In [20]:
plt.imshow(array_dem)
plt.ylabel("pixels")


Out[20]:
<matplotlib.text.Text at 0x1236d29e8>

In [6]:
with fiona.open(sample_points_filepath, 'r') as source_points:
    points = [f['geometry']['coordinates'] for f in source_points]
    
    #plt.figure()
    for f in source_points:
        x, y = f['geometry']['coordinates']
        plt.plot(x, y, 'ro')
    plt.show()
    
    source_points.close()